package com.bachongLightNovel.audit.controller;

import com.bachongLightNovel.audit.service.AuditLogsService;
import com.bachongLightNovel.model.dto.audit.AuditLogsDto;
import com.bachongLightNovel.model.vo.page.PageVo;
import com.bachongLightNovel.model.vo.audit.AuditLogsVo;
import com.bachongLightNovel.result.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author vermouth
 */
@RestController
@RequestMapping("api/audit/audit-logs")
@Slf4j
public class AuditLogsController {


    @Autowired
    private AuditLogsService auditLogsService;

    /**
     * 审核日志分页列表查询
     * @param current: 当前页
     * @param size:    每页显示记录数
     * @param dto:     查询条件
     * @return Result
     */
    @PostMapping("page/{current}/{size}")
    public Result findPage(@PathVariable Integer current,
                           @PathVariable Integer size,
                           @RequestBody AuditLogsDto dto) {
        log.info("审核日志分页列表查询，current:{}，size:{}，query:{}", current, size, dto);
        PageVo<AuditLogsVo> pageVo = auditLogsService.findPage(current, size, dto);
        return Result.success(pageVo);
    }

    /**
     * 根据ID删除审核日志（逻辑删除）
     * @param id:
     * @return Result
     * @author vermouth
     */
    @PutMapping("remove-log/{id}")
    public Result removeLog(@PathVariable Long id){
        log.info("根据ID删除审核日志（逻辑删除）：{}",id);
        auditLogsService.removeLog(id);
        return Result.success();
    }
}
